<template>
	<view v-if="is_init">
		<uni-popup-input @close="on_close">

			<view class="banmi_flex a-c  p-b-30" style="width: 600px;">
				<view class="f-14 c-7" style="width: 110px;">
					名称
				</view>
				<uni-easyinput v-model="find.shop_name" placeholder="请输入名称">
				</uni-easyinput>
			</view>
			<view class="banmi_flex a-c  p-b-30" style="width: 600px;">
				<view class="f-14 c-7" style="width: 110px;">
					分类
				</view>

				<uni-data-select @change="change_nav_id" :value="find.nav_id" :localdata="localdata_nav_id">
				</uni-data-select>

			</view>

			<view class="banmi_flex a-c  p-b-30" style="width: 600px;">
				<view class="f-14 c-7" style="width: 110px;">
					标签(逗号,分开)
				</view>
				<uni-easyinput v-model="find.shop_tag" placeholder="标签">
				</uni-easyinput>
			</view>

			<view class="banmi_flex a-c  p-b-30" style="width: 600px;">
				<view class="f-14 c-7" style="width: 110px;">
					壁纸
				</view>
				<view class="banmi_input_val">
					<upImg ref="upimg" :val='1' name="图片" :count="1" :list="find.shop_img" t_type="images"
						@confirm="confirm_shop_img">
					</upImg>
				</view>
			</view>
			<view class="p20" style="margin-left: 100px;">
				<button class=" " @click="on_users_cx()" type="primary" style="width: 200px;" size="mini">保存</button>
			</view>

		</uni-popup-input>
	</view>
</template>

<script>
	export default {
		components: {

		},
		props: {
			id: {
				type: Number,
				default: 0,

			},
		},
		data() {
			return {
				find: {},
				isShow: false,
				list: [],
				total: 0,
				page: 1,

				is_top_height: false,
				is_init: false,
				localdata_nav_id: []
			}
		},
		mounted() {
			this.init();
			this.nav_init();
		},
		methods: {
			change_nav_id(e) {
				this.find.nav_id = e;
			},
			nav_init() {
				var url = 'banmichaoqiangbizhi/admin/Shoplist/nav_lists';
				this.Http.post(url, {}).then(ret => {

					if (ret.status == 200) {
						var old_list = ret.data.list;
						var list = [];
						for (var i = 0; i < old_list.length; i++) {
							var find = {
								text: old_list[i]['name'],
								value: old_list[i]['id'],
							}
							list.push(find);
						}
						this.localdata_nav_id = list;

					}
				})
			},
			confirm_shop_img(vals) {
				if (vals.length == 0) {
					this.find.shop_img = ''
					return
				}
				this.find.shop_img = vals[0]['attachment']
			},

			maskClick(val) {

				this.find.creation_time = val;
			},
			on_users_cx(index) {
				var that = this;
				let requestParams = that.find;
				var url = 'banmichaoqiangbizhi/admin/Shoplist/updates_bjsjxx';
				if (this.id == 0) {
					url = 'banmichaoqiangbizhi/admin/Shoplist/updates_add';
				}
				this.Http.post(url, requestParams).then(ret => {
					uni.showToast({
						title: ret.msg,
						icon: 'none'
					})
					if (ret.status == 200) {
						this.$emit("confirm");

					}
				})
			},
			init() {
				var that = this;
				var id = that.id;
				if (id == 0) {
					this.is_init = true;
					return
				}
				let requestParams = {
					id: id,
				};
				this.Http.post('banmichaoqiangbizhi/admin/Shoplist/finds_cxsjxq',requestParams).then(ret => {
					if (ret.status == 200) {
				
						this.find = ret.data.find;
						if (!this.find.vip_end_time) {
							this.find.vip_end_time = 0;
						}
						this.is_init = true;
					}
				})
			},
			on_close() {
				this.is_init = false;
				this.$emit("close");
			},


		}
	}
</script>

<style>
	button::after {
		border: none;
	}

	.top_head {
		background-color: #F8F8F8;
		width: 100%;
		top: 0;
		left: 0;
		z-index: 999;
		position: sticky
	}

	.but {
		width: 120rpx;
		height: 100rpx;
		padding: 0;
		border: 0;
		background-color: transparent;
		outline: none;
	}
</style>